package com.thread.lock.money.second;

/**
 * @description:
 * @author: 刘建楼
 * @create: 2021-04-20
 **/
public class DrawThread2 extends Thread {

    private Account2 account2;
    // 当前取钱线程所希望取的钱数
    private double drawAmount;

    public DrawThread2(String name, Account2 account2, double drawAmount) {
        super(name);
        this.account2 = account2;
        this.drawAmount = drawAmount;
    }

    // 当多个账户修改一个共享数据时，将涉及数据安全问题


    @Override
    public void run() {
       account2.draw(drawAmount);
    }

    public Account2 getAccount() {
        return account2;
    }

    public void setAccount(Account2 account2) {
        this.account2 = account2;
    }

    public double getDrawAmount() {
        return drawAmount;
    }

    public void setDrawAmount(double drawAmount) {
        this.drawAmount = drawAmount;
    }
}
